import { roleMenuApi } from '@/api/menu/menu'
import { sessionSet } from '@/utils/sessionStorage'
import { defineStore } from 'pinia'

const menuStore = defineStore('menu', {
  state: () => {
    return {
      menuList: []
    }
  },
  actions: {
    async getMenuList(name) {
      const { data } = await roleMenuApi(name)
      this.menuList = data.router
      sessionSet('menu', this.menuList)
    }
  }
})

export default menuStore
